package com.fancy.projecty.B_流程实例;

import org.activiti.engine.HistoryService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

/**
 * 个人任务的查询
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class L_查询流程实例 {

	@Test
	public void c_() {
		List<HistoricProcessInstance> historicProcessInstanceList =
				historyService.createHistoricProcessInstanceQuery().startedBy("44").list();
		System.out.println("historicProcessInstanceList = " + historicProcessInstanceList);
	}

	@Test
	public void c_1() {
		String a = "qingjia01";
		String assignee = "zhangsan";

		List<Task> list = this.taskService.createTaskQuery()
				.processDefinitionKey(a)
				.taskAssignee(assignee)
				.list();
		for (Task task : list) {
			System.out.println("task = " + task);
		}
	}


	/*历史记录的查询*/
	@Autowired
	private HistoryService historyService;


	@Autowired
	/*管理流程定义,部署相关的Service*/
	private RepositoryService repositoryService;


	@Autowired
	/*执行管理、包括启动、推进、删除流程实例等操作*/
	private RuntimeService runtimeService;


	@Autowired
	/*任务管理,可以做任务的查询的*/
	private TaskService taskService;


}
